﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using 刘颜红销售项目管理.Business.DOM ;
using XDesigner.ORM;
using 刘颜红销售项目管理.Business;

namespace 刘颜红销售项目管理
{
    public partial class frm单位基本信息2 : DevExpress.XtraEditors.XtraForm
    {
        public frm单位基本信息2()
        {
            InitializeComponent();
            strTitle = this.Text;
        }
        
        private string strTitle = null;

        private ORMBindingSource _DataSource = null;

        public ORMBindingSource DataSource
        {
            get { return _DataSource; }
            set { _DataSource = value; }
        }

        public void RefreshView()
        {
            MyApplicationFramework.Instance.ORMEngine.OpenConnection();
            this.DataSource.EnableCheckedProperty = true;
            myGridControl.DataSource = this.DataSource;
            MyApplicationFramework.Instance.ORMEngine.CloseConnection();
        } 

        void ds_Changed(object sender, EventArgs e)
        {
            this.Text = strTitle + "*";
        }

        private void btnNew_Click(object sender, EventArgs e)
        {
            DevExpress.XtraEditors.INavigatableControl ctl = (DevExpress.XtraEditors.INavigatableControl)myGridControl;
            ctl.DoAction(DevExpress.XtraEditors.NavigatorButtonType.Append);
            //DataGridViewRow row = myGridControl myDataGridView.Rows[ myDataGridView.NewRowIndex ] ;
            //row.Selected = true ;
            //myDataGridView.CurrentCell = row.Cells[1];
            //myDataGridView.BeginEdit(false );
        }

        private void frm单位基本信息_Load(object sender, EventArgs e)
        {
            //RefreshView();
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            DevExpress.XtraEditors.INavigatableControl ctl = (DevExpress.XtraEditors.INavigatableControl)myGridControl;
            ctl.DoAction(DevExpress.XtraEditors.NavigatorButtonType.Remove);
        }

        //private SearchResultEnumerator mySearchResult = new SearchResultEnumerator();


        //private void btnSearchPeople_Click(object sender, EventArgs e)
        //{
        //    string name = txtPeopleName.Text.Trim();
        //    if( name.Length == 0 )
        //        return ;
        //    if (mySearchResult.SetCondition(name))
        //    {
        //        ORMBindingSource units = (ORMBindingSource)myGridControl.DataSource;
        //        foreach (Class工作单位 unit in units)
        //        {
        //            if (unit.单位名称 != null && unit.单位名称.IndexOf( name ) >= 0 )
        //            {
        //                mySearchResult.AddResult(unit);
        //            }
        //        }//foreach
        //    }//if
        //    if ( mySearchResult.MoveNext())
        //    {
        //        object current = mySearchResult.Current;
        //        for (int rowIndex = 0; rowIndex < myGridView.RowCount; rowIndex++)
        //        {
        //            Class工作单位 unit = (Class工作单位)myGridView.GetRow(rowIndex);
        //            if (current is Class工作单位)
        //            {
        //                if (unit == current)
        //                {
        //                    myGridView.FocusedRowHandle = rowIndex;
        //                    break;
        //                }
        //            }
        //        }//for
        //    }
        //} 
    }
}